package myJlite.service;

import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;

import jvlite.mvc.annotaion.Insert;
import jvlite.mvc.annotaion.Part;
import myJlite.dao.IAuthDAO;
import myJlite.entity.RoleVO;
import myJlite.entity.StaffVO;
@Part
public class AuthService implements IAuthService {

	@Insert(value = "authDAO")
	private IAuthDAO authDAO;
	
	@Override
	public List<String> readAuth(StaffVO staffVO) throws SQLException{
		RoleVO userAuth = this.authDAO.readAuth(staffVO);
		Integer role_auths = userAuth.getRole_auths().intValue();
		List<String> hasAuthList = null;
		switch (role_auths) {
		case 0:
			hasAuthList = Arrays.asList(new String[]{"guest"});
			break;
		case 1:
			hasAuthList = Arrays.asList(new String[]{"guest", "user"});
			break;
		case 2:
			hasAuthList = Arrays.asList(new String[]{"guest", "operator"});
		case 3:
			hasAuthList = Arrays.asList(new String[]{"guest", "user", "operator"});
		case 5:
			hasAuthList = Arrays.asList(new String[]{"guest", "user", "admin"});
		case 6:
			hasAuthList = Arrays.asList(new String[]{"guest", "operator", "admin"});
		case 7:
			hasAuthList = Arrays.asList(new String[]{"guest", "user", "operator", "admin"});
		default:
			break;
		}
//		DefaultAuthManager.getAuthDataSource().setHasAuthDS(hasAuthList);
		return hasAuthList;
	}
}
